package com.llcbenwu.code;

import io.swagger.models.auth.In;
import lombok.Data;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * 图形验证
 * @author lilinchun
 * @date 2021/10/26 0026 13:48
 */
@Data
public class ImageCode {

    private BufferedImage image;

    /**
     * 验证随机数
     */
    private String code;


    private LocalDateTime  expireTime;

    public ImageCode(BufferedImage image, String code, LocalDateTime expireTime) {
        this.image = image;
        this.code = code;
        this.expireTime = expireTime;
    }

    public ImageCode(BufferedImage image, String code, int expireTime) {
        this.image = image;
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireTime);
    }

    /**
     * 判断当前时间是否比之前的时间大
     * @return
     */
    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }



}
